﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace CommunitySystem.Ctrls
{
    public class MouseTool
    {
        //双击事件定时器
        private System.Windows.Threading.DispatcherTimer _timer;
        //是否单击过一次
        private bool _isFirst;

        public MouseTool()
        {
            this._timer = new System.Windows.Threading.DispatcherTimer();
            this._timer.Interval = new TimeSpan(0, 0, 0, 0, 400);
            this._timer.Tick += new EventHandler(this._timer_Tick);
        }

        /// <summary>
        /// 判断是否双击
        /// </summary>
        /// <returns></returns>
        public bool IsDoubleClick()
        {
            if (!this._isFirst)
            {
                this._isFirst = true;
                this._timer.Start();
                return false;
            }
            else
                return true;
        }

        //间隔时间
        void _timer_Tick(object sender, EventArgs e)
        {
            this._isFirst = false;
            this._timer.Stop();
        }
    }
}
